import asyncio
import os

from dotenv import load_dotenv
from langchain_deepseek import ChatDeepSeek

load_dotenv(override=True)
deepseek_api_key = os.getenv("DEEPSEEK_API_KEY")

# 初始化 deepseek
model = ChatDeepSeek(
    model="deepseek-chat",
    temperature=0,
    max_tokens=None,
    timeout=None,
    max_retries=2,
    api_key=deepseek_api_key,
)


# 异步调用一条请求
async def async_request_method():
    response = await model.ainvoke("解释一下LangChain是什么")
    print("--------------llm请求开始-响应", response)


# 运行异步程序的入口点
print("--------------llm请求开始-前")
asyncio.run(async_request_method())
print("--------------llm请求开始-后")
